import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 在main.js中导入的是全局样式
import './assets/css/global.less'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import { Message } from 'element-ui'
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 请求拦截器 添加token 发生ajax需要使用
axios.interceptors.request.use(config => {
  // 配置请求头
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.prototype.$http = axios
Vue.prototype.$message = Message

Vue.config.productionTip = false

Vue.component('tree-table',TreeTable)// 全局组件                                                                                                                                                                                                                                         

// 定义一个全局的过滤器
Vue.filter('dataFormat',function(val) {
  val = val * 1000
  let dt = new Date(val)
  let y = dt.getFullYear()
  let m = (dt.getMonth() + 1).toString().padStart(2,'0')
  let d = dt.getDate().toString().padStart(2,'0')
  let hh = dt.getHours().toString().padStart(2,'0')
  let mm = dt.getMinutes().toString().padStart(2,'0')
  let ss = dt.getSeconds().toString().padStart(2,'0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

// 编辑器
Vue.use(VueQuillEditor)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
